package com.xm2.demo.system.customer.service;

import com.xm2.demo.system.customer.dao.EvaluateRepository;
import com.xm2.demo.utils.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
 * @Author
 * @Date 2018/12/16 13:39
 * @Description
 */
@Service("evaluateService")
public class EvaluateServiceImpl implements EvaluateService {
    @Autowired
    private EvaluateRepository evaluateRepository;
    @Override
    public Pagination findByEvaluatePage(Pagination pagination) {
        pagination.setTotalRows(evaluateRepository.findAll().size());
        Pageable pageable = new PageRequest(pagination.getCurrentPage(), pagination.getSize(), Sort.Direction.ASC, "id");
        pagination.setList(evaluateRepository.findAll(pageable).getContent());
        return pagination;
    }
}
